{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import threading\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def thread_job():\n",
    "    print('T1 start\\n')\n",
    "    for i in range(10):\n",
    "        time.sleep(0.1)\n",
    "    print('T1 finish\\n')\n",
    "\n",
    "def T2_job():\n",
    "    print('T2 start\\n')\n",
    "    print('T2 finish\\n')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def main():\n",
    "    added_thread = threading.Thread(target=thread_job,name='T1')\n",
    "    thread2 = threading.Thread(target=T2_job,name='T2')\n",
    "    added_thread.start()\n",
    "    thread2.start()\n",
    "    added_thread.join()\n",
    "    print('all done\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "T1 start\n",
      "\n",
      "T2 start\n",
      "\n",
      "T2 finish\n",
      "\n",
      "T1 finish\n",
      "all done\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "if __name__=='__main__':\n",
    "    main()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
